package mmoon.mmoonstory.commands.equip;

import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraft.server.MinecraftServer;

public class CommandEquipChest extends CommandBase {

    @Override
    public String getName() {
        return "chest";
    }

    @Override
    public String getUsage(ICommandSender sender) {
        return "equip chest";
    }

    @Override
    public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
        if (sender instanceof EntityPlayer){
            EntityPlayer player=(EntityPlayer) sender;
            player.setItemStackToSlot(EntityEquipmentSlot.CHEST,player.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND));
            if (!player.isCreative()) {
                player.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.AIR));
            }
        }
    }

    @Override
    public int getRequiredPermissionLevel() {
        return 0;
    }
}

